using("Frame");
DocumentFrame.inherit("Frame");

function DocumentFrame(node){
    this.Frame(node);

	this.getIframe().jsObject=this;
	if (this.getState()=="Expanded"){
		this.updateIframeLocation(true);
	}
}

DocumentFrame.prototype.getUrlHidden = function () {
    return document.getElementById(this.properties.getString("urlControlId"));   
}

DocumentFrame.prototype.getIframe=function () {
	return document.getElementById(this.properties.getString("windowName"));
}

DocumentFrame.prototype.getWindow=function () {
	return window.frames[this.properties.getString("windowName")];
}

DocumentFrame.prototype.reload=function () {
	this.getWindow().history.go(0);	
}


//parametrs should be of type Map
//parameters & expandFrame are optional
DocumentFrame.prototype.load=function (url, expandFrame, parameters){ 		
	this.loaded=false;
	if (parameters instanceof Map){ 
		parameters=parameters.toQueryString();
	} else if (!(parameters instanceof String)) {
		parameters="";
	}
	
	if (url.indexOf("?")==-1){
		url+="?"+parameters;
	} else {
		url+="&"+parameters;
	}
	
	this.getUrlHidden().value=url;
	this.updateIframeLocation(false);
	if (expandFrame){
		this.setOnState();
	}
}	

DocumentFrame.prototype.updateIframeLocation=function (softUpdate) {
	if (softUpdate&&this.loaded){
		return;
	}
	this.getWindow().location.href=this.getUrlHidden().value;
	this.loaded=true;
}

DocumentFrame.prototype.onBeforeExpand=function () {
	this.updateIframeLocation(true);
}
